package homework.day04;

import java.io.*;

/**
 * 将当前目录下的所有obj文件获取到，并进行
 * 反序列化后输出每个用户的信息(直接输出反序
 * 列化后的User对象即可)
 * @author Xiloer
 *
 */
public class Test04 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
//        File dir = new File(".");
//        if (dir.isDirectory()) {
//            File[] subs = dir.listFiles(new FileFilter() {
//                public boolean accept(File file) {
//                    return file.getName().endsWith(".obj");
//                }
//            });
//            System.out.println(subs[0]);


        File dir = new File(".");
        File[] subs = new File[0];
        if(dir.isDirectory()){
            subs = dir.listFiles(new FileFilter() {
                public boolean accept(File file) {
                    return file.getName().endsWith(".obj");
                    }
                }

            );
            System.out.println(subs[0]);
        }
            FileInputStream fis = new FileInputStream(subs[0]);
            ObjectInputStream ois = new ObjectInputStream(fis);
            User o =(User) ois.readObject();
        System.out.println(o);

    }
    }

